<extend name="Public:base" />

<block name="content">

<form action="{:U('Banner/delete')}" method="post">
    <div class="table-responsive">
        <table class="table table-striped table-bordered table-hover search-form" id="nav-table">
            <thead>
            <th><input name="name" type="text" placeholder="输入查找标题" value="{:I('name')}" />
            <a  style="{$update==1?'':'display: none'}" class="btn btn-primary btn-sm radius5" href="{:U('Banner/add')}">添加</a>
            <a class="btn btn-primary btn-sm radius5" href="javascript:;" id="search" url="{:U('Banner/index')}">搜索</a>
            <input  style="{$delete==1?'':'display: none'}" class="btn btn-danger btn-sm radius5" id="delete" value="删除" type="submit">
            </th>
            </thead>
        </table>
    </div>
</form>

    <div class="table-responsive">
        <table class="table table-striped table-bordered table-hover" id="mytable">

            <thead>
            <tr>
                <th><input name="Fruit" id="all" type="checkbox" value="" /><label for="all">全选</label></th>
                <th>序号</th>
                <th>标题</th>
                <th>封面图</th>
                <th>类型</th>
                <th>内容</th>
                <th>状态</th>
                <th>添加时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <volist name="banner" id="ba">
                <tr>
                    <td><input class="che" name="ids[]" type="checkbox" value="{$ba.id}" /></td>
                    <td>{$ba.id}</td>
                    <td>{$ba.title}</td>
                    <td><img src="{$ba.pic}" style="width: 200px;height: 150px"></td>
                    <td>{$ba['type']==1?'业主端':'师傅端'}</td>
                    <td>{$ba.desc}</td>
                    <td>{$ba['status']==1?'启用':'停用'}</td>
                    <td>{$ba.add_time|date="Y-m-d H:i:s",###}</td>
                    <td><a  style="{$update==1?'':'display: none'}" href="{:U('Banner/edit').'&id='.$ba['id']}" class="btn btn-xs btn-info radius5">编辑</a></td>

                </tr>
            </volist>
            <tr>
                <td colspan="20" class="page">{$page}</td>
            </tr>
            </tbody>

        </table>
    </div>

</block>
<block name="javascript">
    <script>
        var le=0;
        $(function(){
            $("#search").click(function () {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input,select').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });

                $("#all").click(function() {
                 console.log(this.checked)
                    $(".che").attr("checked",this.checked);
                })
            });
               $('#delete').click(function(){
                  console.log( $('.che').length)
                   for(var i=0;i<$('.che').length;i++){
                       if($('.che')[i].checked==true){
                           le+=1;
                       }
                   }
                   if(le==0){
                       alert('选择不能为空');
                       return false;
                   }
               });
              $('.che').click(function(){
                  console.log(this.checked)
              })
    </script>
</block>